package org.thingsboard.server.dao.custom;

import com.google.common.util.concurrent.ListenableFuture;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.thingsboard.server.common.data.custom.DeviceGroup;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.id.custom.DeviceGroupId;
import org.thingsboard.server.dao.entity.AbstractEntityService;

import javax.annotation.Resource;

import static org.thingsboard.server.dao.service.Validator.validateId;


@Service
@Slf4j
public class DeviceGroupServiceImpl extends AbstractEntityService implements DeviceGroupService{

    @Resource
    private DeviceGroupDao deviceGroupDao;


    @Override
    public DeviceGroup findGroupById(TenantId tenantId, DeviceGroupId groupId) {
        return deviceGroupDao.findById(tenantId, groupId.getId());
    }

    @Override
    public DeviceGroup createOrUpdateDeviceGroup(DeviceGroup deviceGroup) {
        return null;
    }

    @Override
    public ListenableFuture<DeviceGroup> findGroupByIdAsync(TenantId tenantId, DeviceGroupId groupId) {

        log.trace("Executing findAlarmById [{}]", groupId);
        validateId(groupId, "Incorrect alarmId " + groupId);
        return deviceGroupDao.findByIdAsync(tenantId, groupId.getId());
    }
}
